package com.yf.controller;

import com.yf.dto.Message;
import com.yf.dto.Result;
import com.yf.entity.WorkType;
import com.yf.myException.ExceptionEnum;
import com.yf.myException.NewException;
import com.yf.service.WorkTypeService;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@CrossOrigin
@ResponseBody
@RequiresAuthentication
public class WorkTypeController {

    @Autowired
    private WorkTypeService workTypeService;

    /**
     * 获取任务类型列表
     * @return
     */
    @RequiresAuthentication
    @RequestMapping(value = "/getWorkTypes")
    public Result getWorkTypeList(){
        try {
            List<WorkType> workTypeList = workTypeService.getWorkTypeList();
            Result result = new Result();
            result.setMessage(new Message());
            result.setObj(workTypeList);
            return result;
        } catch (Exception e) {
            throw new NewException(ExceptionEnum.ERROR_GET);
        }
    }

}
